﻿//
//  Copyright (c) 2011 Extreme: Paweł Huryn (lead), Jakub Domański
//


using System;

namespace Extreme.SPFramework.DependencyInjection
{
    /// <summary>
    /// Service attribute used by Service Provider.
    /// It is possible to specify implemented typed directly [Service(Type t)] OR 
    /// use [Service] to register all implemented interfaces.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)] 
    public class ServiceAttribute : Attribute
    {
        /// <summary>
        /// Will registrate all interfaces
        /// </summary>
        public ServiceAttribute()
        { 
        }

        /// <summary>
        /// Will registrate all interfaces
        /// </summary>
        /// <param name="lifestyle">Component lifestyle type</param>
        public ServiceAttribute(LifestyleType lifestyle)
        {
            Lifestyle = lifestyle;
        }

        /// <summary>
        /// Implemented type
        /// </summary>
        /// <param name="implementedInterface">Interface to register</param>
        public ServiceAttribute(Type implementedInterface)
        {
            Interface = implementedInterface;
        }

        /// <summary>
        /// Implemented type
        /// </summary>
        /// <param name="implementedInterface">Interface to register</param>
        /// <param name="lifestyle">Component lifestyle type</param>
        public ServiceAttribute(Type implementedInterface, LifestyleType lifestyle)
        {
            Interface = implementedInterface;
            Lifestyle = lifestyle;
        }

        /// <summary>
        /// Type of interface
        /// </summary>
        public Type Interface
        {
            get;
            private set;
        }

        /// <summary>
        /// Lifestyle type
        /// </summary>
        public LifestyleType? Lifestyle
        {
            get; 
            private set; 
        }
    }
}
